package com.ziyun.erp.modules.material.service.impl;

import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import com.ziyun.erp.modules.material.dao.ErpStockDao;
import com.ziyun.erp.modules.material.entity.ErpStockEntity;
import com.ziyun.erp.modules.material.service.ErpStockService;


@Service("erpStockService")
public class ErpStockServiceImpl extends ServiceImpl<ErpStockDao, ErpStockEntity> implements ErpStockService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<ErpStockEntity> page = this.selectPage(
                new Query<ErpStockEntity>(params).getPage(),
                new EntityWrapper<ErpStockEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void deleteUpdate(Integer stockId, Long userId) {
        Map<String,Object> updateMap = new HashMap<>();
        updateMap.put("delete",1);
        updateMap.put("update_name",userId);
        baseMapper.updateByMap(updateMap,stockId);

    }

    @Override
    public Integer getStockId(Integer sellerId) {
        return baseMapper.getStockId(sellerId);
    }
}
